<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="用户ID" prop="userId">
      <el-input v-model="dataForm.userId" placeholder="用户ID"></el-input>
    </el-form-item>
    <el-form-item label="会员码" prop="specialId">
      <el-input v-model="dataForm.specialId" placeholder="会员码"></el-input>
    </el-form-item>
    <el-form-item label="用户名" prop="username">
      <el-input v-model="dataForm.username" placeholder="用户名"></el-input>
    </el-form-item>
    <el-form-item label="账户余额" prop="amount">
      <el-input v-model="dataForm.amount" placeholder="账户余额"></el-input>
    </el-form-item>
    <el-form-item label="我的佣金" prop="brokerage">
      <el-input v-model="dataForm.brokerage" placeholder="我的佣金"></el-input>
    </el-form-item>
    <el-form-item label="订单号" prop="dmlOrdersn">
      <el-input v-model="dataForm.dmlOrdersn" placeholder="订单号"></el-input>
    </el-form-item>
    <el-form-item label="详情" prop="dmlLog">
      <el-input v-model="dataForm.dmlLog" placeholder="详情"></el-input>
    </el-form-item>
    <el-form-item label="转入金额" prop="dmlMoney">
      <el-input v-model="dataForm.dmlMoney" placeholder="转入金额"></el-input>
    </el-form-item>
    <el-form-item label="" prop="dmlType">
      <el-input v-model="dataForm.dmlType" placeholder=""></el-input>
    </el-form-item>
    <el-form-item label="审核状态" prop="dmlStatus">
      <el-input v-model="dataForm.dmlStatus" placeholder="审核状态"></el-input>
    </el-form-item>
    <el-form-item label="交易单号" prop="dmlTradesn">
      <el-input v-model="dataForm.dmlTradesn" placeholder="交易单号"></el-input>
    </el-form-item>
    <el-form-item label="申请日期" prop="dmlAddtime">
      <el-input v-model="dataForm.dmlAddtime" placeholder="申请日期"></el-input>
    </el-form-item>
    <el-form-item label="审批日期" prop="dmlAudittime">
      <el-input v-model="dataForm.dmlAudittime" placeholder="审批日期"></el-input>
    </el-form-item>
    <el-form-item label="ip" prop="ip">
      <el-input v-model="dataForm.ip" placeholder="ip"></el-input>
    </el-form-item>
    <el-form-item label="审批日期" prop="executant">
      <el-input v-model="dataForm.executant" placeholder="审批日期"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          dmlId: 0,
          userId: '',
          specialId: '',
          username: '',
          amount: '',
          brokerage: '',
          dmlOrdersn: '',
          dmlLog: '',
          dmlMoney: '',
          dmlType: '',
          dmlStatus: '',
          dmlTradesn: '',
          dmlAddtime: '',
          dmlAudittime: '',
          ip: '',
          executant: ''
        },
        dataRule: {
          userId: [
            { required: true, message: '用户ID不能为空', trigger: 'blur' }
          ],
          specialId: [
            { required: true, message: '会员码不能为空', trigger: 'blur' }
          ],
          username: [
            { required: true, message: '用户名不能为空', trigger: 'blur' }
          ],
          amount: [
            { required: true, message: '账户余额不能为空', trigger: 'blur' }
          ],
          brokerage: [
            { required: true, message: '我的佣金不能为空', trigger: 'blur' }
          ],
          dmlOrdersn: [
            { required: true, message: '订单号不能为空', trigger: 'blur' }
          ],
          dmlLog: [
            { required: true, message: '详情不能为空', trigger: 'blur' }
          ],
          dmlMoney: [
            { required: true, message: '转入金额不能为空', trigger: 'blur' }
          ],
          dmlType: [
            { required: true, message: '不能为空', trigger: 'blur' }
          ],
          dmlStatus: [
            { required: true, message: '审核状态不能为空', trigger: 'blur' }
          ],
          dmlTradesn: [
            { required: true, message: '交易单号不能为空', trigger: 'blur' }
          ],
          dmlAddtime: [
            { required: true, message: '申请日期不能为空', trigger: 'blur' }
          ],
          dmlAudittime: [
            { required: true, message: '审批日期不能为空', trigger: 'blur' }
          ],
          ip: [
            { required: true, message: 'ip不能为空', trigger: 'blur' }
          ],
          executant: [
            { required: true, message: '审批日期不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.dmlId = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.dmlId) {
            this.$http({
              url: this.$http.adornUrl(`/draw_money_log/v9drawmoneylog/info/${this.dataForm.dmlId}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.userId = data.v9DrawMoneyLog.userId
                this.dataForm.specialId = data.v9DrawMoneyLog.specialId
                this.dataForm.username = data.v9DrawMoneyLog.username
                this.dataForm.amount = data.v9DrawMoneyLog.amount
                this.dataForm.brokerage = data.v9DrawMoneyLog.brokerage
                this.dataForm.dmlOrdersn = data.v9DrawMoneyLog.dmlOrdersn
                this.dataForm.dmlLog = data.v9DrawMoneyLog.dmlLog
                this.dataForm.dmlMoney = data.v9DrawMoneyLog.dmlMoney
                this.dataForm.dmlType = data.v9DrawMoneyLog.dmlType
                this.dataForm.dmlStatus = data.v9DrawMoneyLog.dmlStatus
                this.dataForm.dmlTradesn = data.v9DrawMoneyLog.dmlTradesn
                this.dataForm.dmlAddtime = data.v9DrawMoneyLog.dmlAddtime
                this.dataForm.dmlAudittime = data.v9DrawMoneyLog.dmlAudittime
                this.dataForm.ip = data.v9DrawMoneyLog.ip
                this.dataForm.executant = data.v9DrawMoneyLog.executant
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/draw_money_log/v9drawmoneylog/${!this.dataForm.dmlId ? 'save' : 'update'}`),
              method: 'post',
              data: this.$http.adornData({
                'dmlId': this.dataForm.dmlId || undefined,
                'userId': this.dataForm.userId,
                'specialId': this.dataForm.specialId,
                'username': this.dataForm.username,
                'amount': this.dataForm.amount,
                'brokerage': this.dataForm.brokerage,
                'dmlOrdersn': this.dataForm.dmlOrdersn,
                'dmlLog': this.dataForm.dmlLog,
                'dmlMoney': this.dataForm.dmlMoney,
                'dmlType': this.dataForm.dmlType,
                'dmlStatus': this.dataForm.dmlStatus,
                'dmlTradesn': this.dataForm.dmlTradesn,
                'dmlAddtime': this.dataForm.dmlAddtime,
                'dmlAudittime': this.dataForm.dmlAudittime,
                'ip': this.dataForm.ip,
                'executant': this.dataForm.executant
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
 
